// Package
// @Author zhongxc
// @Date 2024/7/2 16:38:00
// @Desc
package main

import (
	"github.com/gin-gonic/gin"
	"google.golang.org/grpc/reflection"
	"vben-admin/config"
	"vben-admin/pkg/svc"
	"vben-admin/router"
	srv "vben-common"
)

func main() {
	svcCtx := svc.NewServiceContext(config.C)

	r := gin.Default()
	// 路由
	router.InitRouter(r)
	// grpc服务注册
	grpcServer := router.RegisterGrpc(svcCtx)
	// 注册反射服务
	reflection.Register(grpcServer)

	stopGrpcServer := func() {
		grpcServer.Stop()
	}

	// grpc服务注册到etcd
	router.RegisterEtcdServer()

	srv.Run(r, config.C.SC.Name, config.C.SC.Addr, stopGrpcServer)
}
